var listPage = avalon.define({
	$id: "listPage",
	uid: "",
	loginName: "",
	password: "",
	password1: "",
	validate: {
		onValidateAll: function(reasons) {
			if(reasons.length) {
				mui.toast(reasons[reasons.length-1].getMessage());
			} else {
				var form = $("#addForm");
				mui.ajax('/user/add/sub.json', {
					data: form.serialize(),
					dataType: 'json',
					type: 'post',
					success: function(data) {
						console.log(data);
						if(1==data.status){
							mui.alert(data.msg, ' ', function() {
								// var url = "dahua://registerBack";
								var url = "./index.html";
								mui.openWindow({
									url: url 
								});
							});
						}else if(2==data.status){
							mui.alert($.i18n.prop('subaccount_exists'));
						}else{
							mui.alert(data.msg, ' ', function() {});
						}
						
					}
				});
			}
		}
	}
});

mui.ready(function() {
	var uid = $("#uid").val();
	listPage.uid = uid;
});
